package org.com.myfb.action;

import org.com.myfb.model.Person;
import org.com.myfb.service.PersonServiceInter;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class LoginAction extends ActionSupport{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Person person;
	private String data;
	private PersonServiceInter personServiceImpl;
	public Person getPerson() {
		return person;
	}
	public void setPerson(Person person) {
		this.person = person;
	}
	public String getData() {
		return data;
	}
	public void setData(String data) {
		this.data = data;
	}
	
	
	public PersonServiceInter getPersonServiceImpl() {
		return personServiceImpl;
	}
	public void setPersonServiceImpl(PersonServiceInter personServiceImpl) {
		this.personServiceImpl = personServiceImpl;
	}
	public String execute(){
		if(this.getPersonServiceImpl().loginService(this.getPerson())) {
			if(this.getPerson().getPower()==1){
				setData("SUCCESS");
				return "success_teachers";
			}else{
				setData("SUCCESS");
				return "success_students";
			}
		} else {
			setData("ERROR");
			return ERROR;			
		}
	}
}
